package com.travel.JPA;

import com.travel.Bean.Manager;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

public interface ManagerJPA extends JpaRepository<Manager,Integer> {

    @Query("select count(m) from Manager m where m.username = ?1 and m.password=?2")
    Integer findByUsernameAnAndPassword(String username,String password);

    @Query("select m from Manager m where m.username=?1")
    Manager findByUsername(String username);

    @Query("select id from Manager where username = ?1")
    Integer findIdByUsername(String username);

    @Modifying
    @Query("delete from Manager where id = ?1")
    Integer deleteByid(Integer id);

    @Query("select culture_id from Manager where username = ?1")
    Integer findCultureIdByManagerNameAnd(String name);

    @Modifying
    @Query("update Manager set culture_id = ?1 where username = ?2")
    Integer updateManagerCid(Integer culture_id,String usernmae);

    @Query("select m from Manager m where m.culture_id = ?1")
    List<Manager> findManagersByCulture_id(Integer culture_id);

}
